/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 */
package com.yxw.live_vod_boot.controller;


import lombok.extern.slf4j.Slf4j;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.GetMapping;

import org.springframework.web.bind.annotation.RequestParam;
import javax.validation.constraints.NotBlank;
import org.springframework.web.bind.annotation.PathVariable;
import com.yxw.yxnet_cd_center.common.utils.BaseResult;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.Api;
import com.yxw.live_vod_facade.dto.YxLiveShopReportDTO;
import com.yxw.live_vod_boot.dto.LiveShopReporAddtDTO;
import com.yxw.live_vod_boot.dto.LiveShopReporUserQueryDTO;
import com.yxw.live_vod_boot.dto.YxLiveWatchLogAddDTO;
import com.yxw.live_vod_boot.entity.YxLiveActivityProductsEntity;
import com.yxw.live_vod_boot.entity.YxLiveShopReportEntity;
import com.yxw.live_vod_boot.entity.YxLiveShopUserEntity;
import com.yxw.live_vod_boot.service.IYxLiveShopReportService;
import com.yxw.live_vod_boot.service.LiveGeneraUserProcessService;
import com.yxw.live_vod_boot.service.LiveRecommendService;
import com.yxw.live_vod_boot.service.LiveProcessService;
import com.yxw.live_vod_facade.vo.LiveActivityProductsVO;
import com.yxw.live_vod_boot.vo.LiveOnlineInRedisCacheVO;
import com.yxw.live_vod_facade.dto.UserGetPlayURLDTO;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.multipart.MultipartFile; 
import io.swagger.annotations.ApiImplicitParams; 
 import io.swagger.annotations.ApiImplicitParam;
import org.springframework.beans.factory.annotation.Autowired;
/*

import org.springframework.web.bind.annotation.RequestParam;
import javax.validation.constraints.NotNull;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletRequest;
import java.io.UnsupportedEncodingException;
import org.springframework.web.bind.annotation.GetMapping;

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
*/


/**
 * 直播处理逻辑服务
 * @author hjx
 * @date 2023-12-15
 * @update 2023-12-15
 */
@Slf4j
@Api(value = "直播普通用户相关的操作", tags = {"直播普通用户相关的操作"})
@RestController
@RequestMapping("/api/live/user")
public class LiveGeneraUserProcessController {
    @Autowired
    private IYxLiveShopReportService oYxLiveShopReportService;
    
    @Autowired
    private LiveGeneraUserProcessService oLiveGeneraUserProcessService;
    
    @Autowired
    private LiveRecommendService oLiveRecommendService;
    
    @Autowired
    private LiveProcessService oLiveProcessService;
    /*** 
    * 根据店铺Id查询店铺在线员工
    * @param liveShopId
    * @param userId
    * @return List<YxLiveShopUserEntity>
    **/
    @ApiOperation(value ="根据userId和店铺id查询店铺员工信息",notes = "此接口用于根据userId和店铺id查询店铺员工信息")
    @ApiResponses({@ApiResponse(code = 200,message = "OK",response = YxLiveShopUserEntity.class),})
    @GetMapping("/getShopUserInfor/{liveShopId}/{userId}")
    public BaseResult getShopUserInfor(@PathVariable @NotNull(message = "店铺内建id不能为空") Long liveShopId,@PathVariable @NotNull(message = "userId不能为空") Long userId)
    {
        return oLiveGeneraUserProcessService.getShopUserInfor(liveShopId,userId);
    }    
    /*
    获取一条直播推荐
    */
    @ApiOperation(value ="获取一条直播推荐",notes = "此接口用于获取一条直播推荐荐")
    @ApiResponses({@ApiResponse(code = 200,message = "OK",response = LiveOnlineInRedisCacheVO.class),})
    @GetMapping("/userGetOneLiveRecommend/{userId}")     
    public BaseResult liveUserGetOneLiveRecommend(HttpServletRequest httpRequest,@PathVariable @NotNull(message = "userId不能为空") Long userId)
    {
        return oLiveRecommendService.liveUserGetOneLiveRecommend(userId);
    }
    /*
    按分页获取直播推荐
    */
    @ApiOperation(value ="按分页获取直播推荐",notes = "此接口用于按分页获取直播推荐")
    @ApiResponses({@ApiResponse(code = 200,message = "OK",response = LiveOnlineInRedisCacheVO.class),})
    @GetMapping("/userGetLiveRecommendPage/{currentPage}/{pageSize}/{userId}")    
    public BaseResult liveUserGetLiveRecommendPage(HttpServletRequest httpRequest,@PathVariable @NotBlank(message = "当前分页currentPage不能为空") Long currentPage,@PathVariable @NotBlank(message = "分页大小pageSize不能为空") Long pageSize,@PathVariable @NotNull(message = "userId不能为空") Long userId)
    {
        return oLiveRecommendService.liveUserGetLiveRecommendPage(currentPage, pageSize, userId);
    }
    /**
     * 用户获取直播间播放地址
     * @param LiveShopAddUserDTO
     * @return BaseResult
     */
    @ApiOperation(value ="用户获取直播间播放地址",notes = "此接口用于用户获取直播间播放地址")
    @ApiResponses({@ApiResponse(code = 200,message = "OK",response = YxLiveShopReportEntity.class),})
    @PostMapping("/userGetPlayURL")    
    public BaseResult userGetPlayURL(HttpServletRequest httpRequest,@RequestPart @Valid UserGetPlayURLDTO userGetPlayURLDTO)
    {
        return oLiveProcessService.userGetPlayURL(httpRequest, userGetPlayURLDTO);
    }
    
    /*** 
    * 用户举报店铺直播
    * @param oYxLiveShopReportDTO
    * @return BaseResult
    **/
    @ApiOperation(value ="用户举报店铺直播", notes = "此接口用于用户举报店铺直播")
    @ApiResponses({@ApiResponse(code = 200,message = "OK",response = YxLiveShopReportEntity.class),})
    @ApiImplicitParams({         
            @ApiImplicitParam(paramType = "multipart/form-data",name = "accusationPicture", value = "举报图片", dataType = "__file")
    })//, required = true
    @PostMapping("/userReportLiveShop")
    public BaseResult userReportLiveShop(HttpServletRequest httpRequest,MultipartFile accusationPicture,LiveShopReporAddtDTO oLiveShopReporAddtDTO)
    {
        return oYxLiveShopReportService.insertYxLiveShopReport(httpRequest,accusationPicture,oLiveShopReporAddtDTO);
    }

    /*** 
    * 删除店铺被举报表
    * @param id
    * @param oYxLiveShopReportDTO
    * @return BaseResult

    @ApiOperation(value ="删除店铺被举报表YxLiveShopReport",notes = "此接口用于删除店铺被举报表信息")
    @ApiResponses({@ApiResponse(code = 200,message = "OK",response = BaseResult.class),})
    @GetMapping("/removeYxLiveShopReport/{id}")
    public BaseResult removeYxLiveShopReport(@PathVariable @NotNull(message = "id不能为空")Long id)
    {
            return oYxLiveShopReportService.deleteYxLiveShopReportById(id);
    }
   **/
    /*** 
    * 根据id查找店铺被举报表
    * @param id
    * @param oYxLiveShopReportDTO
    * @return YxLiveShopReportEntity
    **/
    @ApiOperation(value ="根据id查找店铺被举报表",notes = "此接口用于根据id查找店铺被举报表信息")
    @ApiResponses({@ApiResponse(code = 200,message = "OK",response = YxLiveShopReportEntity.class),})
    @GetMapping("/getLiveShopReportInfo/{id}")
    public BaseResult getLiveShopReportInfo(HttpServletRequest httpRequest,@PathVariable @NotNull(message = "id不能为空") Long id,@RequestBody @Valid YxLiveShopReportDTO oYxLiveShopReportDTO)
    {
        return BaseResult.success(oYxLiveShopReportService.selectYxLiveShopReportById(httpRequest,id));
    }
    /*** 
    * 管理员查询店铺被举报记录
    * @param currentPage 当前页
    * @param pageSize 分页大小
    * @param oYxLiveShopReportDTO
    * @return Page
   
    @ApiOperation(value ="管理员查询店铺被举报记录",notes = "此接口用于管理员查询店铺被举报记录")
    @ApiResponses({@ApiResponse(code = 200,message = "OK",response = YxLiveShopReportEntity.class),})
    @PostMapping("/managerQuewryLiveShopReportPage/{currentPage}/{pageSize}")
    public BaseResult managerQuewryLiveShopReportPage(HttpServletRequest httpRequest,@PathVariable int currentPage,@PathVariable int pageSize,@RequestBody LiveShopReporManagerQueryDTO oLiveShopReporManagerQueryDTO)
    {
        return oYxLiveShopReportService.managerQuewryLiveShopReportPage(httpRequest,currentPage,pageSize,oLiveShopReporManagerQueryDTO);
    }
    **/
    /*** 
    * 用户查询举报记录
    * @param oYxLiveShopReportDTO
    * @return List<YxLiveShopReportEntity>
    **/
    @ApiOperation(value ="用户查询举报记录",notes = "此接口用于用户查询举报记录")
    @ApiResponses({@ApiResponse(code = 200,message = "OK",response = YxLiveShopReportEntity.class),})
    @PostMapping("/userQuewryLiveShopReportPage/{currentPage}/{pageSize}")
    public BaseResult userQuewryLiveShopReportPage(HttpServletRequest httpRequest,@PathVariable int currentPage,@PathVariable int pageSize,@RequestBody @Valid LiveShopReporUserQueryDTO oLiveShopReporUserQueryDTO)
    {
        return oYxLiveShopReportService.userQuewryLiveShopReportPage(httpRequest,currentPage,pageSize,oLiveShopReporUserQueryDTO);
    }    
    /**
     * 用户进入直播间
     * @param  liveId
     * @return BaseResult
     */
    @ApiOperation(value = "用户进入直播间")
    @ApiResponses({@ApiResponse(code = 200,message = "OK",response = BaseResult.class),})
    @GetMapping(value = "/userComeInLiveHome/{liveId}")    
    public BaseResult userGoIntoLiveHome(HttpServletRequest httpRequest,@PathVariable @NotBlank(message = "直播id不能为空") String liveId)
    {
        return oLiveGeneraUserProcessService.userGoIntoLiveHome(httpRequest, liveId);
    }
    /**
     * 用户退出直播间
     * @param  liveId
     * @return BaseResult
     */
    @ApiOperation(value = "用户退出直播间")
    @ApiResponses({@ApiResponse(code = 200,message = "OK",response = BaseResult.class),})
    @GetMapping(value = "/userGoOutLiveHome/{liveId}")    
    public BaseResult userLeaveLiveHome(HttpServletRequest httpRequest,@PathVariable @NotBlank(message = "直播id不能为空") String liveId)
    {
        return oLiveGeneraUserProcessService.userLeaveLiveHome(httpRequest, liveId);
    }
    /**
     * 查询直播间用户数量
     * @param  liveId
     * @return BaseResult
     */
    @ApiOperation(value = "查询直播间用户数量")
    @ApiResponses({@ApiResponse(code = 200,message = "OK",response = BaseResult.class),})
    @GetMapping(value = "/getLiveHomeUserCount/{liveId}")       
    public BaseResult getLiveHomeUserCount(@PathVariable @NotBlank(message = "直播id不能为空") String liveId)
    {
        return oLiveGeneraUserProcessService.getLiveHomeUserCount(liveId);
    }
    /**
     * 用户直播拉流日志推送
     * @param  liveId
     * @return BaseResult
     */
    @ApiOperation(value = "用户直播拉流日志推送")
    @ApiResponses({@ApiResponse(code = 200,message = "OK",response = BaseResult.class),})
    @GetMapping(value = "/userLiveStreamPushLog")    
    public BaseResult userLiveStreamPushLog(HttpServletRequest httpRequest,@RequestBody @Valid YxLiveWatchLogAddDTO oYxLiveWatchLogAddDTO)
    {
        return oLiveGeneraUserProcessService.liveWatchLogAddToCache(oYxLiveWatchLogAddDTO);
    }
    /**
     * 查看店铺是否在开播
     * @param  liveShopId
     * @return BaseResult
     */
    @ApiOperation(value = "查看店铺是否在开播")
    @ApiResponses({@ApiResponse(code = 200,message = "OK",response = BaseResult.class),})
    @GetMapping(value = "/userCheckShopLiveStreamIsActive/{liveShopId}")    
    public BaseResult userCheckShopLiveStreamIsActive(@PathVariable @NotNull(message = "店铺liveShopId不能为空") Long liveShopId)
    {
        return oLiveGeneraUserProcessService.userCheckShopLiveStreamIsActive(liveShopId);
    } 
    /*** 
    * 商品_根据直播Id获取小黄车的商品 
    * @param liveShopId
    * @return List<YxLiveActivityProductsEntity>
    **/
    @ApiOperation(value ="商品_根据直播Id获取小黄车的商品")
    @ApiResponses({@ApiResponse(code = 200,message = "OK",response = LiveActivityProductsVO.class),})
    @GetMapping("/liveActivityProductsGetOnlineList")
    public BaseResult liveActivityProductsGetOnlineList(@RequestParam @NotBlank(message = "直播Id:liveId不能为空") String liveId)
    {
        return BaseResult.success(oLiveRecommendService.liveActivityProductsGetOnlineList(liveId));
    }    
}
